//
//  SWSettingViewController.m
//  ShiWu
//
//  Created by liujianlong on 2022/7/28.
//

#import "SWSettingViewController.h"
#import "SWSettinngCell.h"

#import "SWFeedbackViewController.h"
#import "SWPrivacyViewController.h"
@interface SWSettingViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tablview;
@property (nonatomic, strong) NSArray *titles;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *tableviewH;

@end

@implementation SWSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.titles = @[@"意见反馈",@"隐私政策"];
    self.title = LS(@"设置");
    [self.tablview registerNib:[SWSettinngCell nib] forCellReuseIdentifier:[SWSettinngCell ID]];
    self.tableviewH.constant = self.titles.count * 44;
    self.tablview.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    if (@available(iOS 11, *))
    {
        self.tablview.contentInsetAdjustmentBehavior  = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.titles.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SWSettinngCell *cell = [tableView dequeueReusableCellWithIdentifier:[SWSettinngCell ID]];
    cell.name.text = LS(self.titles[indexPath.row]);
    cell.separatorInset = UIEdgeInsetsZero;
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *title = self.titles[indexPath.row];
    if ([title isEqualToString:@"意见反馈"]) {
        SWFeedbackViewController *vc = [[SWFeedbackViewController alloc] init];
        vc.title = LS(title);
        [self.navigationController pushViewController:vc animated:YES];
    }else if ([title isEqualToString:@"隐私政策"])
    {
        SWPrivacyViewController *vc = [[SWPrivacyViewController alloc] init];
        vc.title = LS(title);
        [self.navigationController pushViewController:vc animated:YES];
    }
}
@end
